<template>
    <view class="myAccount">
        <view class="formTitle" v-if="pageName != 'problem'">
            {{ title }}
        </view>
        <view class="form-view">
            <view class="formLabel" v-if="pageName == 'baseSet'">
                <view class="formLabelItem">
                    登录账号:
                </view>
                <view class="formLabelItem">
                    手机号码:
                </view>
                <view class="formLabelItem">
                    登录密码:
                </view>
                <view class="formLabelItem">
                    确认密码:
                </view>
                <view class="formLabelItem">
                    登录网址:
                </view>
            </view>
            <view class="formLabel" v-if="pageName == 'safety'">
                <view class="formLabelItem">
                    手机认证:
                </view>
                <!-- <view class="formLabelItem" style="margin-top: 40rpx;">
                    谷歌绑定:
                </view> -->
            </view>
            <view class="informationOut" :style="pageName == 'problem' ? {width: '90%', marginTop: '0'} : {}">
                <u-form :model="baseLoginForm" ref="uForm" v-if="pageName == 'baseSet'">
                    <u-form-item label="" prop="name">
                        <u-input v-model="baseLoginForm.phone" placeholder="登录账号"/>
                    </u-form-item>
                    <u-form-item label="" prop="name">
                        <u-input v-model="baseLoginForm.phone" placeholder="手机号码" />
                    </u-form-item>
                    <u-form-item label="" prop="name">
                        <u-input v-model="baseLoginForm.pwd" type="password" placeholder="登录密码"
                            :password-icon="true" />
                    </u-form-item>

                    <u-form-item label="" prop="name">
                        <u-input v-model="baseLoginForm.pwd_copy" type="password" placeholder="确认密码"
                            :password-icon="true" />
                    </u-form-item>
                    <view class="formLabelItem" style="color: #ebd093;">
                        www.lf.bet
                    </view>
                </u-form>

                <u-form :model="baseLoginForm" ref="uForm" v-if="pageName == 'safety'">
                    <u-form-item label="" prop="name" style="height: 94rpx;">
                        <u-input v-model="baseLoginForm.phone" placeholder="手机绑定" />
                        <view class="bind" @click="updatepwd">绑定</view>
                    </u-form-item>
                   <!-- <u-form-item label="" prop="name" style="height: 94rpx;margin-top: 20rpx;">
                        <u-input v-model="baseLoginForm.name" placeholder="谷歌绑定" />
                        <view class="bind">绑定</view>
                    </u-form-item> -->
                </u-form>
				<scroll-view class="myAccount-guid" scroll-y="auto"  scroll-x="auto" v-if="pageName == 'problem'">
					<image class="my-guid-img" src="../../static/img/user/tip.png" mode=""></image>
				</scroll-view>
            </view>
        </view>
        <view class="form-post" v-if="pageName == 'baseSet'">
            <view class="save-user-form" @click="updatepwd"  style="margin-right: 20rpx;">
                保存设置
            </view>
			<view class="save-user-form" @click="goOut()" >
			    退出登录
			</view>
        </view>
    </view>
</template>

<script>
	import api from "@/api/api"
    export default {
        props: ['page'],
        data() {
            return {
                pageName: 'baseSet',
                title: '账户设置 - 登录设置',
                baseLoginForm: {}
            };
        },
        watch: {
            'page': function(val) {
                if (val) {
                    /* baseSet
                     safety
                     problem */
                    this.pageName = val
                    if (this.pageName == 'baseSet') {
                        this.title = '账户设置 - 登录设置'
                    } else if (this.pageName == 'safety') {
                        this.title = '安全认证'
                    }

                }
            }
        },
		methods: {
			updatepwd() {
				let pwds =  this.baseLoginForm;
				
				if(pwds.pwd  != pwds.pwd_copy){
					this.$tip.error('两次密码不一致!')
					return;
				}
				
				api.updateLogin(this.baseLoginForm).then((res) => {
					if (res.data.code == 200) {
						this.$tip.success(res.data.message)
						this.$router.push('/pages/login/login')	
					}else{
						this.$tip.error(res.data.message)
					}
				})
			},
			goOut(){
				uni.removeStorageSync('login_user_info')
				uni.removeStorageSync('Access-Token')
				this.$router.push('/pages/login/login')
			}
			
		}
    }
</script>

<style lang="scss" scoped>
    .formTitle {
        color: #FFFFFF;
        margin-left: 12rpx;
    }

    .form-view {
        display: flex;

        .formLabelItem {
            height: 72rpx;
            line-height: 72rpx;
            font-size: 28rpx;
            color: #FFFFFF;
        }

        .formLabel {
            margin-left: 60rpx;
            width: 18%;
            padding: 8rpx 0;
            margin-top: 25px;
        }

        .informationOut {
            width: 74%;
            margin: auto;
            border: 1px solid #c3ad86;
            border-radius: 8px;
            margin-top: 25px;
            padding: 8rpx 20rpx;

            /deep/ .u-form-item {
                padding: 0;
            }
        }
    }

    .form-post {
        display: flex;
        justify-content: flex-end;
        margin-top: 40rpx;

        .save-user-form {
            width: 260rpx;
            height: 64rpx;
			line-height: 64rpx;
            border-radius: 32rpx;
			border: 1px solid #d8bf88;
			color: white;
			display: flex;
			justify-content: center;
			align-items: center;
        }
    }
	.myAccount-guid{
		height: 690rpx;
		// display: flex;
		.my-guid-img{
			width: 620rpx;
			height: calc(620rpx * 4.24525);
		}
	}
    .bind {
        width: 160rpx;
        height: 80rpx;
        line-height: 80rpx;
        text-align: center;
        border-radius: 40rpx;
        border: 2rpx solid #4Fd561;
        color: #4fd561;
    }
	
	.u-input /deep/ .u-input__input{
		color: white;
	}
</style>
